package pojo;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonBackReference;

/**
 * RECEIVE FROM M
 * @author ZHENGNI3
 *
 */
@Entity
@GenericGenerator(strategy="uuid",name="uuid_advertisement")
public class Advertisement {
	@Id
	@GeneratedValue(generator="uuid_advertisement")
	private String id;
	private String imgPath;
	private double adPrice;
	private String foodId;
	private String foodName;
	private Double foodPrice;
	@Temporal(TemporalType.TIMESTAMP)
	private Date startTime;
	@Temporal(TemporalType.TIMESTAMP)
	private Date endTime;
	private String status;
	
	@ManyToOne(targetEntity = Merchant.class)
	@JoinColumn(name="m_id")
	@JsonBackReference
	private Merchant merchant;
	
	public Advertisement(){}
	public Advertisement(String id, double adPrice) {
		super();
		this.id = id;
		this.adPrice = adPrice;
	}
		
	public Advertisement(String imgPath, double adPrice, String foodId, String foodName, Double foodPrice,
			Date startTime, Date endTime, Merchant merchant) {
		super();
		this.imgPath = imgPath;
		this.adPrice = adPrice;
		this.foodId = foodId;
		this.foodName = foodName;
		this.foodPrice = foodPrice;
		this.startTime = startTime;
		this.endTime = endTime;
		this.merchant = merchant;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getImgPath() {
		return imgPath;
	}
	public void setImgPath(String imgPath) {
		this.imgPath = imgPath;
	}
	public double getAdPrice() {
		return adPrice;
	}
	public void setAdPrice(double adPrice) {
		this.adPrice = adPrice;
	}
	public String getFoodId() {
		return foodId;
	}
	public void setFoodId(String foodId) {
		this.foodId = foodId;
	}
	public Date getStartTime() {
		return startTime;
	}
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	public String getFoodName() {
		return foodName;
	}
	public void setFoodName(String foodName) {
		this.foodName = foodName;
	}
	public Double getFoodPrice() {
		return foodPrice;
	}
	public void setFoodPrice(Double foodPrice) {
		this.foodPrice = foodPrice;
	}
	public Merchant getMerchant() {
		return merchant;
	}
	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}
	
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Override
	public String toString() {
		return "Advertisement [id=" + id + ", imgPath=" + imgPath + ", adPrice=" + adPrice + ", foodId=" + foodId
				+ ", foodName=" + foodName + ", foodPrice=" + foodPrice + ", startTime=" + startTime + ", endTime="
				+ endTime + ", merchant=" + merchant + "]";
	}

}
